import {Component, Input, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {DocumentService} from '../shared/document.service';
import {Document} from '../shared/document.model';

@Component({
  selector: 'app-document-detail',
  templateUrl: './document-detail.component.html',
  styleUrls: ['./document-detail.component.css']
})
export class DocumentDetailComponent implements OnInit {

  public document: Document;

  constructor(private documentService: DocumentService,  private activatedRoute: ActivatedRoute) { }

  ngOnInit() {
    const documentId = this.activatedRoute.snapshot.paramMap.get('id');
    this.document = this.documentService.currentDocument;

    this.documentService.getDocument(documentId).subscribe( (document: Document) => {
      this.document = document;
    });
  }
}
